local skel = fk.CreateSkill{
  name = "lb__zaohuang_view",
}

Fk:loadTranslationTable{
  ["lb__zaohuang_view"] = "凿荒",
  [":lb__zaohuang_view"] = "你可以使用装备区中的非装备牌。",
}

skel:addEffect("viewas", {
  prompt = "#lb__zaohuang_view",
  pattern = ".",
  card_filter = function (self, player, to_select, selected)
    local ids = Fk:currentRoom():getBanner("lb__zaohuang_"..player.id) or {}
    local eid = table.filter(ids, function (vid)
      return table.find(player:getCardIds("e"), function (id)
        return Fk:getCardById(vid, true):getMark("lb_zaohuang") == id
      end) ~= nil
    end)
    return #selected == 0 and table.contains(eid, to_select)
  end,
  expand_pile = function (self, player)
    local ids = Fk:currentRoom():getBanner("lb__zaohuang_"..player.id) or {}
    return table.filter(ids, function (vid)
      return table.find(player:getCardIds("e"), function (id)
        return Fk:getCardById(vid, true):getMark("lb_zaohuang") == id
      end) ~= nil
    end)
  end,
  view_as = function (self, player, cards)
    if #cards ~= 1 then return nil end
    local id = Fk:getCardById(cards[1], true):getMark("lb_zaohuang")
    return id ~= 0 and Fk:getCardById(id, true) or nil
  end,
  enabled_at_play = function(self, player)
    return player:getMark("@@lb__zaohuang") > 0 and table.find(player:getCardIds("e"),function (id)
      local card = Fk:getCardById(id, true)
      if Fk.currentResponsePattern == nil then
        return card.type ~= Card.TypeEquip and player:canUse(card)
      else
        return card.type ~= Card.TypeEquip and Exppattern:Parse(Fk.currentResponsePattern):match(card)
      end
    end)
  end,
  enabled_at_response = function (self, player, response)
    return not response and player:getMark("@@lb__zaohuang") > 0 and table.find(player:getCardIds("e"),function (id)
      local card = Fk:getCardById(id, true)
      if Fk.currentResponsePattern == nil then
        return card.type ~= Card.TypeEquip and player:canUse(card)
      else
        return card.type ~= Card.TypeEquip and Exppattern:Parse(Fk.currentResponsePattern):match(card)
      end
    end)
  end,
})

return skel